#!/bin/bash
zstor_dir="/dev/shm/zstorage"

# Return the value
case $1 in
  health)
    flock -s -o -w 2 ${zstor_dir}/health.lock -c "echo $(cat ${zstor_dir}/health.dat)"
  ;;
  cluster_total)
    flock -s -o -w 2 ${zstor_dir}/cluster_total.lock -c "echo $(cat ${zstor_dir}/cluster_total.dat)"
  ;;
  cluster_used)
    flock -s -o -w 2 ${zstor_dir}/cluster_used.lock -c "echo $(cat ${zstor_dir}/cluster_used.dat)"
  ;;
  cluster_used_percent)
    flock -s -o -w 2 ${zstor_dir}/cluster_used_percent.lock -c "echo $(cat ${zstor_dir}/cluster_used_percent.dat)"
  ;;
  cluster_free)
    flock -s -o -w 2 ${zstor_dir}/cluster_free.lock -c "echo $(cat ${zstor_dir}/cluster_free.dat)"
  ;;
  mon)
    flock -s -o -w 2 ${zstor_dir}/mon.lock -c "echo $(cat ${zstor_dir}/mon.dat)"
  ;;
  mon_count)
    flock -s -o -w 2 ${zstor_dir}/mon_count.lock -c "echo $(cat ${zstor_dir}/mon_count.dat)"
  ;;
  mon_proc_count)
    flock -s -o -w 2 ${zstor_dir}/mon_proc_count.lock -c "echo $(cat ${zstor_dir}/mon_proc_count.dat)"
  ;;
  osd_count)
    flock -s -o -w 2 ${zstor_dir}/osd_count.lock -c "echo $(cat ${zstor_dir}/osd_count.dat)"
  ;;
  osd_proc_count)
    flock -s -o -w 2 ${zstor_dir}/osd_proc_count.lock -c "echo $(cat ${zstor_dir}/osd_proc_count.dat)"
  ;;
  osd_up)
    flock -s -o -w 2 ${zstor_dir}/osd_up.lock -c "echo $(cat ${zstor_dir}/osd_up.dat)"
  ;;
  osd_in)
    flock -s -o -w 2 ${zstor_dir}/osd_in.lock -c "echo $(cat ${zstor_dir}/osd_in.dat)"
  ;;
  degraded_percent)
    flock -s -o -w 2 ${zstor_dir}/degraded_percent.lock -c "echo $(cat ${zstor_dir}/degraded_percent.dat)"
  ;;
  pgtotal)
    flock -s -o -w 2 ${zstor_dir}/pgtotal.lock -c "echo $(cat ${zstor_dir}/pgtotal.dat)"
  ;;
  creating)
    flock -s -o -w 2 ${zstor_dir}/creating.lock -c "echo $(cat ${zstor_dir}/creating.dat)"
  ;;
  active_clean)
    flock -s -o -w 2 ${zstor_dir}/active_clean.lock -c "echo $(cat ${zstor_dir}/active_clean.dat)"
  ;;
  inactive)
    flock -s -o -w 2 ${zstor_dir}/inactive.lock -c "echo $(cat ${zstor_dir}/inactive.dat)"
  ;;
  unclean)
    flock -s -o -w 2 ${zstor_dir}/unclean.lock -c "echo $(cat ${zstor_dir}/unclean.dat)"
  ;;
  down)
    flock -s -o -w 2 ${zstor_dir}/down.lock -c "echo $(cat ${zstor_dir}/down.dat)"
  ;;
  replay)
    flock -s -o -w 2 ${zstor_dir}/replay.lock -c "echo $(cat ${zstor_dir}/replay.dat)"
  ;;
  splitting)
    flock -s -o -w 2 ${zstor_dir}/splitting.lock -c "echo $(cat ${zstor_dir}/splitting.dat)"
  ;;
  scrubbing)
    flock -s -o -w 2 ${zstor_dir}/scrubbing.lock -c "echo $(cat ${zstor_dir}/scrubbing.dat)"
  ;;
  degraded)
    flock -s -o -w 2 ${zstor_dir}/degraded.lock -c "echo $(cat ${zstor_dir}/degraded.dat)"
  ;;
  inconsistent)
    flock -s -o -w 2 ${zstor_dir}/inconsistent.lock -c "echo $(cat ${zstor_dir}/inconsistent.dat)"
  ;;
  peering)
    flock -s -o -w 2 ${zstor_dir}/peering.lock -c "echo $(cat ${zstor_dir}/peering.dat)"
  ;;
  repair)
    flock -s -o -w 2 ${zstor_dir}/repair.lock -c "echo $(cat ${zstor_dir}/repair.dat)"
  ;;
  recovering)
    flock -s -o -w 2 ${zstor_dir}/recovering.lock -c "echo $(cat ${zstor_dir}/recovering.dat)"
  ;;
  backfill)
    flock -s -o -w 2 ${zstor_dir}/backfill.lock -c "echo $(cat ${zstor_dir}/backfill.dat)"
  ;;
  waitBackfill)
    flock -s -o -w 2 ${zstor_dir}/waitBackfill.lock -c "echo $(cat ${zstor_dir}/waitBackfill.dat)"
  ;;
  incomplete)
    flock -s -o -w 2 ${zstor_dir}/incomplete.lock -c "echo $(cat ${zstor_dir}/incomplete.dat)"
  ;;
  stale)
    flock -s -o -w 2 ${zstor_dir}/stale.lock -c "echo $(cat ${zstor_dir}/stale.dat)"
  ;;
  remapped)
    flock -s -o -w 2 ${zstor_dir}/remapped.lock -c "echo $(cat ${zstor_dir}/remapped.dat)"
  ;;
  ops)
    flock -s -o -w 2 ${zstor_dir}/ops.lock -c "echo $(cat ${zstor_dir}/ops.dat)"
  ;;
  wrbps)
    flock -s -o -w 2 ${zstor_dir}/wrbps.lock -c "echo $(cat ${zstor_dir}/wrbps.dat)"
  ;;
  rdbps)
    flock -s -o -w 2 ${zstor_dir}/rdbps.lock -c "echo $(cat ${zstor_dir}/rdbps.dat)"
  ;;
esac

